<?php

declare (strict_types=1);
namespace App\Model;

use App\Constants\Constant;
use Hyperf\DbConnection\Db;
use Hyperf\DbConnection\Model\Model;

/**
 * @property int $works_id 
 * @property string $title 
 * @property string $uri
 * @property int $child_name
 * @property string $child_photo
 * @property string $content
 * @property string $teacher_name
 * @property string $teacher_photo
 * @property string $teacher_comment
 * @property string $add_time
 */
class Works extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'works';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['title','uri','child_name','child_photo','content','teacher_name','teacher_photo','teacher_comment'];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['works_id' => 'integer', 'child_id' => 'integer'];

    protected $primaryKey = "works_id";

    public $timestamps = false;

    public function agrees(){
        return $this->hasMany(Agree::class,"source_id","works_id")->where("origin",Constant::ORIGIN_WORKS);
    }
}